﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using XmlStudio.Interfaces;

namespace XmlStudio.Models.Actions {
    internal sealed class RemoveDocumentTypeAction : XmlModelAction {
        #region Fields
        private XmlDocumentType oldDocumentType;
        #endregion

        #region Constructors
        public RemoveDocumentTypeAction(IXmlModelWithNotifications model)
            : base(model) {
            this.oldDocumentType = model.DocumentType;
        }
        #endregion

        protected override void ExecuteCore() {
            this.model.DocumentType = null;
            this.model.OnRawXmlChanged(new Events.RawXmlChangedEventArgs());
        }

        protected override void UnExecuteCore() {
            this.model.DocumentType = oldDocumentType;
            this.model.OnRawXmlChanged(new Events.RawXmlChangedEventArgs());
        }
    }
}
